﻿


namespace System.Data.Services.Providers
{
    #region Namespaces
    using System.Collections.Generic;
    using System.Diagnostics;
    using Microsoft.Data.Edm;
    using Microsoft.Data.Edm.Annotations;
    using Microsoft.Data.Edm.Library;
    using Microsoft.Data.Edm.Library.Annotations;
    using Microsoft.Data.Edm.Library.Values;
    using Microsoft.Data.Edm.Values;
    using Microsoft.Data.Edm.EdmToClrConversion;
    using Microsoft.Data.OData.Evaluation;
    #endregion Namespaces

    internal sealed class MetadataProviderEdmEnumType : EdmEnumTypeWithMembers, IResourceTypeBasedEdmType
    {
        internal MetadataProviderEdmEnumType(
            string namespaceName,
            ResourceType resourceType,
            IEdmPrimitiveType underlyingType,
            bool isFlags)
            : base(resourceType.InstanceType, namespaceName, resourceType.Name, underlyingType, isFlags)
        {

            Debug.Assert(resourceType != null, "resourceType != null");
            Debug.Assert(resourceType.ResourceTypeKind == ResourceTypeKind.EnumType, "Must be a enum type.");
            this.ResourceType = resourceType;
            //string[] names = Enum.GetNames(resourceType.InstanceType);
            //Array values = Enum.GetValues(resourceType.InstanceType);

            //Type baseType = Enum.GetUnderlyingType(resourceType.InstanceType);

            //for (int i = 0; i < names.Length; i++)
            //{
            //    object value = Convert.ChangeType(values.GetValue(i), baseType);
            //    IEdmPrimitiveValue pValue = EdmValueUtils.ConvertPrimitiveValue(value, null) as IEdmPrimitiveValue;
            //    this.AddMember(names[i], pValue);
            //}
        }

        /// <summary>
        /// The resource-type that this type was created from.
        /// </summary>
        public ResourceType ResourceType { get; private set; }
    }
}
